Page({
  data: {
    navHeight: 0,
    userList: [
      {
        id: 1,
        name: '小红',
        age: 25,
        avatar: '/assets/images/avatar1.png'
      },
      {
        id: 2,
        name: '小明',
        age: 27,
        avatar: '/assets/images/avatar2.png'
      },
      {
        id: 3,
        name: '小花',
        age: 24,
        avatar: '/assets/images/avatar3.png'
      },
      {
        id: 4,
        name: '小强',
        age: 26,
        avatar: '/assets/images/avatar4.png'
      }
    ]
  },

  onLoad() {
    // 获取系统信息设置导航栏高度
    const systemInfo = wx.getSystemInfoSync();
    const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
    const navHeight = menuButtonInfo.top + menuButtonInfo.height;
    
    this.setData({
      navHeight: navHeight
    });
  },

  // 点击用户卡片
  onTapUserCard(e) {
    const userId = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: `/pages/userDetail/index?id=${userId}`
    });
  },

  // 底部按钮点击事件
  onTapBottomButton(e) {
    const type = e.currentTarget.dataset.type;
    switch(type) {
      case 'write':
        wx.navigateTo({ url: '/pages/write/index' });
        break;
      case 'search':
        wx.navigateTo({ url: '/pages/search/index' });
        break;
      case 'myList':
        wx.navigateTo({ url: '/pages/myList/index' });
        break;
    }
  }
}); 